<%-- 
    Document   : register
    Created on : Feb 28, 2012, 1:01:48 PM
    Author     : chenwei
--%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    String[] propertyText = {"ID",
        "Name",
        "Nationality",
        "Graduate",
        "Department",
        "Email",
        "Phone Number"};
    List propertyTextList = Arrays.asList(propertyText);

    String[] propertyTextfield = {"id",
        "name",
        "nationality",
        "graduate",
        "department",
        "email",
        "phone"};
    List propertyTextfieldList = Arrays.asList(propertyTextfield);

    request.setAttribute("propertyTextList", propertyTextList);
    request.setAttribute("propertyTextfieldList", propertyTextfieldList);
    
    session.setAttribute("propertyTextList", propertyTextList);
    session.setAttribute("propertyTextfieldList", propertyTextfieldList);
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Register a new student</title>

        <style type="text/css">
            #main {
                text-align: right;
                margin-top: 50px;
            }

            .text {
                width: 120px;
                text-align: right;
                font-weight: bold;
            }

            .textfield {
            }

            .input {
                text-align: center;
                padding-top: 10px;
            }

            body {
                text-align: center;
            }
            
            a {
                text-decoration: none;
                color: black;
            }

            table {
                margin: auto;
            }

            tr,td {
                padding-top: 3px;
                padding-left: 6px;
                padding-right: 6px;
                margin: 3px;
            }
        </style>
    </head>
    <body>
        <a href="/students"><h1>Register a new student</h1></a>
        <form method="post" action="/students/register" name="register">
            <div id="main">
                <table>
                    <c:forEach items="${propertyTextList}" var="propertyItem" varStatus="loop">
                        <tr>
                            <td>
                                <div class="text">
                                    <c:out value="${propertyItem}"/>: 
                                </div>
                            </td>
                            <td>
                                <div class="textfield">
                                    <input type="text" name="${propertyTextfieldList[loop.count - 1]}" />
                                </div>
                            </td>
                        </tr>
                    </c:forEach>
                    <tr>
                        <td>
                            <div class="input">
                                <input type="submit" value="Submit" /> 
                            </div>
                        </td>
                        <td>
                            <div class="input">
                                <input type="reset" name="Reset" />
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </body>
</html>
